<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title>CloningStrategy xref</title>
<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
</head>
<body>
<div id="overview"><a href="../../../../../apidocs/com/googlecode/transloader/clone/CloningStrategy.html">View Javadoc</a></div><pre>

<a name="1" href="#1">1</a>   <strong class="jxr_keyword">package</strong> com.googlecode.transloader.clone;
<a name="2" href="#2">2</a>   
<a name="3" href="#3">3</a>   <strong class="jxr_keyword">import</strong> com.googlecode.transloader.clone.reflect.MaximalCloningDecisionStrategy;
<a name="4" href="#4">4</a>   <strong class="jxr_keyword">import</strong> com.googlecode.transloader.clone.reflect.MinimalCloningDecisionStrategy;
<a name="5" href="#5">5</a>   <strong class="jxr_keyword">import</strong> com.googlecode.transloader.clone.reflect.ObjenesisInstantiationStrategy;
<a name="6" href="#6">6</a>   <strong class="jxr_keyword">import</strong> com.googlecode.transloader.clone.reflect.ReflectionCloningStrategy;
<a name="7" href="#7">7</a>   
<a name="8" href="#8">8</a>   <em class="jxr_javadoccomment">/**</em>
<a name="9" href="#9">9</a>   <em class="jxr_javadoccomment"> * The API by which an object can be cloned using a different &lt;code&gt;ClassLoader&lt;/code&gt; than that/those which loaded</em>
<a name="10" href="#10">10</a>  <em class="jxr_javadoccomment"> * the &lt;code&gt;Class&lt;/code&gt;es it references. It can be used directly or serves as the strategy interface for</em>
<a name="11" href="#11">11</a>  <em class="jxr_javadoccomment"> * customising the behaviour of {@link com.googlecode.transloader.ObjectWrapper}s.</em>
<a name="12" href="#12">12</a>  <em class="jxr_javadoccomment"> * </em>
<a name="13" href="#13">13</a>  <em class="jxr_javadoccomment"> * @author Jeremy Wales</em>
<a name="14" href="#14">14</a>  <em class="jxr_javadoccomment"> */</em>
<a name="15" href="#15">15</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../com/googlecode/transloader/clone/CloningStrategy.html">CloningStrategy</a> {
<a name="16" href="#16">16</a>  	<em class="jxr_javadoccomment">/**</em>
<a name="17" href="#17">17</a>  <em class="jxr_javadoccomment">	 * The implementation which clones as little as possible to make the given object graph use &lt;code&gt;Class&lt;/code&gt;es</em>
<a name="18" href="#18">18</a>  <em class="jxr_javadoccomment">	 * that are the same as those that would be loaded through the given &lt;code&gt;ClassLoader&lt;/code&gt;. This is the most</em>
<a name="19" href="#19">19</a>  <em class="jxr_javadoccomment">	 * efficient implementation to use simply for the purpose of making sure the returned object graph is perfectly</em>
<a name="20" href="#20">20</a>  <em class="jxr_javadoccomment">	 * compatible with all other objects referencing &lt;code&gt;Class&lt;/code&gt;es loaded through the given</em>
<a name="21" href="#21">21</a>  <em class="jxr_javadoccomment">	 * &lt;code&gt;ClassLoader&lt;/code&gt;. It is also the implementation that is most likely to succeed in cloning any given</em>
<a name="22" href="#22">22</a>  <em class="jxr_javadoccomment">	 * object graph because by attempting to clone as few objects as possible it is less likely to attempt to clone an</em>
<a name="23" href="#23">23</a>  <em class="jxr_javadoccomment">	 * object that cannot be cloned (e.g. a non-{@link java.io.Serializable} with &lt;code&gt;final&lt;/code&gt; fields in a</em>
<a name="24" href="#24">24</a>  <em class="jxr_javadoccomment">	 * pre-Java-5 JVM).</em>
<a name="25" href="#25">25</a>  <em class="jxr_javadoccomment">	 * &lt;p&gt;</em>
<a name="26" href="#26">26</a>  <em class="jxr_javadoccomment">	 * However, the fact that it only clones what is necessary to make the object graph compatible with the given</em>
<a name="27" href="#27">27</a>  <em class="jxr_javadoccomment">	 * &lt;code&gt;ClassLoader&lt;/code&gt; means that usually &lt;b&gt;not all&lt;/b&gt; of the objects in the graph will be cloned. This</em>
<a name="28" href="#28">28</a>  <em class="jxr_javadoccomment">	 * means that, depending on the &lt;code&gt;Class&lt;/code&gt;es in the object graph and which of these is the same if loaded</em>
<a name="29" href="#29">29</a>  <em class="jxr_javadoccomment">	 * through the given &lt;code&gt;ClassLoader&lt;/code&gt;, it is possible that a top level object is not cloned but objects</em>
<a name="30" href="#30">30</a>  <em class="jxr_javadoccomment">	 * it references through fields are cloned. This effectively means that the existing object graph can be altered</em>
<a name="31" href="#31">31</a>  <em class="jxr_javadoccomment">	 * rather than a new, purely seperate object graph being created. This &lt;b&gt;may not be what you want&lt;/b&gt; if you want</em>
<a name="32" href="#32">32</a>  <em class="jxr_javadoccomment">	 * to continue using the given object in its original context. In which case, use {@link CloningStrategy#MAXIMAL}.</em>
<a name="33" href="#33">33</a>  <em class="jxr_javadoccomment">	 * &lt;/p&gt;</em>
<a name="34" href="#34">34</a>  <em class="jxr_javadoccomment">	 * </em>
<a name="35" href="#35">35</a>  <em class="jxr_javadoccomment">	 * @see ReflectionCloningStrategy</em>
<a name="36" href="#36">36</a>  <em class="jxr_javadoccomment">	 * @see MinimalCloningDecisionStrategy</em>
<a name="37" href="#37">37</a>  <em class="jxr_javadoccomment">	 */</em>
<a name="38" href="#38">38</a>  	CloningStrategy MINIMAL =
<a name="39" href="#39">39</a>  			<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/reflect/ReflectionCloningStrategy.html">ReflectionCloningStrategy</a>(<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/reflect/MinimalCloningDecisionStrategy.html">MinimalCloningDecisionStrategy</a>(), <strong class="jxr_keyword">new</strong> ObjenesisInstantiationStrategy(),
<a name="40" href="#40">40</a>  					<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/SerializationCloningStrategy.html">SerializationCloningStrategy</a>());
<a name="41" href="#41">41</a>  
<a name="42" href="#42">42</a>  	<em class="jxr_javadoccomment">/**</em>
<a name="43" href="#43">43</a>  <em class="jxr_javadoccomment">	 * The implementation which clones every &lt;code&gt;Object&lt;/code&gt; in the given object graph. The given object graph is</em>
<a name="44" href="#44">44</a>  <em class="jxr_javadoccomment">	 * not altered in any way and a completely new copy of the object graph referencing only &lt;code&gt;Class&lt;/code&gt;es</em>
<a name="45" href="#45">45</a>  <em class="jxr_javadoccomment">	 * loaded through the given &lt;code&gt;ClassLoader&lt;/code&gt; is returned. Only primitives, which are not</em>
<a name="46" href="#46">46</a>  <em class="jxr_javadoccomment">	 * &lt;code&gt;Object&lt;/code&gt;s, are not cloned because they cannot be, as there is no concept of different references to</em>
<a name="47" href="#47">47</a>  <em class="jxr_javadoccomment">	 * the same primitive value in Java. Similiar in behaviour to {@link SerializationCloningStrategy} except that it</em>
<a name="48" href="#48">48</a>  <em class="jxr_javadoccomment">	 * can clone more object graphs because it does not rely on all referenced objects being</em>
<a name="49" href="#49">49</a>  <em class="jxr_javadoccomment">	 * {@link java.io.Serializable} and also performs much faster than serialization.</em>
<a name="50" href="#50">50</a>  <em class="jxr_javadoccomment">	 * </em>
<a name="51" href="#51">51</a>  <em class="jxr_javadoccomment">	 * @see ReflectionCloningStrategy</em>
<a name="52" href="#52">52</a>  <em class="jxr_javadoccomment">	 * @see MaximalCloningDecisionStrategy</em>
<a name="53" href="#53">53</a>  <em class="jxr_javadoccomment">	 */</em>
<a name="54" href="#54">54</a>  	CloningStrategy MAXIMAL =
<a name="55" href="#55">55</a>  			<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/reflect/ReflectionCloningStrategy.html">ReflectionCloningStrategy</a>(<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/reflect/MaximalCloningDecisionStrategy.html">MaximalCloningDecisionStrategy</a>(), <strong class="jxr_keyword">new</strong> ObjenesisInstantiationStrategy(),
<a name="56" href="#56">56</a>  					<strong class="jxr_keyword">new</strong> <a href="../../../../com/googlecode/transloader/clone/SerializationCloningStrategy.html">SerializationCloningStrategy</a>());
<a name="57" href="#57">57</a>  
<a name="58" href="#58">58</a>  	<em class="jxr_javadoccomment">/**</em>
<a name="59" href="#59">59</a>  <em class="jxr_javadoccomment">	 * Clones the given object using the given &lt;code&gt;ClassLoader&lt;/code&gt;.</em>
<a name="60" href="#60">60</a>  <em class="jxr_javadoccomment">	 * </em>
<a name="61" href="#61">61</a>  <em class="jxr_javadoccomment">	 * @param original the original object to be cloned</em>
<a name="62" href="#62">62</a>  <em class="jxr_javadoccomment">	 * @param targetClassLoader the &lt;code&gt;ClassLoader&lt;/code&gt; by which to load &lt;code&gt;Class&lt;/code&gt;es for clones</em>
<a name="63" href="#63">63</a>  <em class="jxr_javadoccomment">	 * @return the result of cloning the object graph</em>
<a name="64" href="#64">64</a>  <em class="jxr_javadoccomment">	 * @throws Exception can throw any &lt;code&gt;Exception&lt;/code&gt; depending on the implementation</em>
<a name="65" href="#65">65</a>  <em class="jxr_javadoccomment">	 */</em>
<a name="66" href="#66">66</a>  	Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader) <strong class="jxr_keyword">throws</strong> Exception;
<a name="67" href="#67">67</a>  }
</pre>
<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
</html>

